
Question 5/5
"Shopping Cart"
Your solution will be scored against a series of unit test cases.
Environment:
This IDE environment gives you access to a Linux based virtual machine.
Your current setup includes the following frameworks installed:
Important: You must use a personal machine and network to avoid firewall/proxy issues.
A few tips:
Problem Statement:
In this assessment, you will have to implement an API service for an online shopping cart.
Sample product Object:
{
"id": "1234",
"name": "product1",
"price": 200,
"quantity": 1
}
Sample Catalog Object:
{
"products": [{
"id": "001",
"name": "chair",
"price": 295,
"quantity": 1
}, ...]
}
Sample Cart Object:
{
"products": [{
"id": "001",
"name": "chair",
"price": 295
}],
"totalCost": 295
}
You will have to implement the following API endpoints:
// For Example:
// Request URL: /catalog/size
// Success Response body, statusCode should be 200
{
"success": true,
"count": 94
}
// Failure Response body, statusCode should be 501, in case products.json file is not found
{
"success": false
}
// For example:
// Request URL: /catalog/001
// Success Response body, statusCode should be 200
{
"products": [
{
"id": "001",
"name": "chair",
"price": 295,
"quantity": 1
}
],
"success": true
}
// Request URL: /catalog/00000000
// Failure Response body, statusCode should be 404, since product is not found
{
"success": false
}
// For example:
// Request URL: /cart
// Success Response body, statusCode should be 200
{
"products": [
{
"id": "001",
"name": "chair",
"price": 295,
"quantity": 1
}
],
"totalCost": 295 // if products array is empty then totalCost should be 0"success": true
}
// Request URL: /cart
// Failure Response body, statusCode should be 501
{
"success": false
}
// For example:
// Request URL: /cart/item/001
// Success Response body, statusCode should be 200
{
"products": [
{
"id": "001",
"name": "chair",
"price": 295,
"quantity": 1
}
],
"success": true
}
// Request URL: /cart/002
// Failure Response body, statusCode should be 404, since product with 002 is not present in the cart
{
"success": false
}
// For example:
// Request URL: /cart/item/001
// Success Response body, statusCode should be 200
{
"success": true
}
// Request URL: /cart/00000
// Failure Response body, statusCode should be 404, since product is not found
{
"success": false
}
// NOTE:
// In case if you try to add the same product twice, then it should return 501 with above body
// as product is already added to cart
// For example:
// Request URL: /cart/item/001
// Success Response body, statusCode should be 200
{
"success": true
}
// Request URL: /cart/00000
// Failure Response body, statusCode should be 404, since product is not found
{
"success": false
}
// NOTE:
// In case if you try to remove the same product twice, then it should return 404 with above body
// as product is already removed from cart
// For example:
// Request URL: /cart/checkout
// Success Response body, statusCode should be 200
{
"products": [
{
"id": "001",
"name": "chair",
"price": 295,
"quantity": 1
}
],
"totalCost": 295"success": true
}
// Request URL: /cart/checkoout, in case oif cart is empty then it should return following body
// Failure Response body, statusCode should be 501
{
"success": false
}
Note:
Bootstrap
VueJS
HTML/CSS/JS
EmberJS
ReactJS
Angular 10
Bootstrap
VueJS
HTML/CSS/JS
EmberJS
ReactJS
Angular 10